# -*- mode: Awk; -*-  vim: set filetype=awk :
#
# This file is part of GLEE,  copyright Tim Menzies 2010, 
# tim@menzies.us  
# 
# GLEE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GLEE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GLEE.  If not, see <http://www.gnu.org/licenses/>.

BEGIN      { Comment="#" }
/^[ \t]*$/ { dump(); next; }
           { Text = (Text ? Text "\n" : "" ) $0 }
END        { dump() }

function dump() {
    if (Text) 
			print dump1(Text) "\n"
	Text=""
}
function dump1(text) {
	if (text ~ /^[ \t][ \t][ \t]/)
		return text 
	if (text ~ /^[ \t][ \t]/)
	    return comment(text)
	if (text ~ /^[ \t]/)
	    return text 
	return comment(text)
}  
function comment(text) {
	 gsub(/\n/,"\n" Comment,text);
	 return Comment text   
}
